<?php

class NewsController extends Controller {

    public function actionIndex($nickname = '') {        
        $criteria = new CDbCriteria();
        $criteria->compare('active', 1);
        $criteria->compare('category', $nickname);
        $criteria->order = 'date desc';
        $count = News::model()->count($criteria);
        $pages = new CPagination($count);
        $pages->pageSize = 4;
        $pages->applyLimit($criteria);
        $models = News::model()->findAll($criteria);
        $this->render('index', array('models' => $models, 'pages' => $pages));
    }

}
